package com.movitech.mobile.cz.base.sys.controller;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.plugins.Page;
import com.movitech.mobile.cz.base.modules.controller.RestReturnResult;
import com.movitech.mobile.cz.base.sys.bizvo.SRegionalCompanyAreaUpdateRequestVO;
import com.movitech.mobile.cz.base.sys.entity.SRegionalCompanyArea;
import com.movitech.mobile.cz.base.sys.service.SRegionalCompanyAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
 * <p>
 * SRegionalCompanyArea 前端控制器
 * </p>
 *
 * @author Movitech Mobile
 * @since 2018-04-26
 */
@RestController
@RequestMapping("/v1/sRegionalCompanyArea")
@Api(value = "地区公司与地区的关联关系基础操作接口", description = "地区公司与地区的关联关系基础操作接口")
public class SRegionalCompanyAreaController {
    @Autowired
    private SRegionalCompanyAreaService sRegionalCompanyAreaService;

    @GetMapping("/allList")
    @ApiOperation(
            value = "获取所有地区公司与地区的关联关系接口",
            notes = "获取所有地区公司与地区的关联关系接口",
            response = SRegionalCompanyArea.class
    )
    public RestReturnResult list() {
    	RestReturnResult restResult = RestReturnResult.success();
        Page<SRegionalCompanyArea> page = sRegionalCompanyAreaService.selectPage(new Page<SRegionalCompanyArea>());
        restResult.setData(page);
        return restResult;
    }

    @PostMapping("/searchList/{pageNumber}")
    @ApiOperation(
            value = "地区公司与地区的关联关系列表查询接口",
            notes = "地区公司与地区的关联关系列表查询接口",
            response = SRegionalCompanyArea.class
    )
    public RestReturnResult searchList(@RequestBody SRegionalCompanyArea sRegionalCompanyArea,
                @ApiParam(value = "分页页数")@PathVariable Integer pageNumber) {
    	RestReturnResult restResult = RestReturnResult.success();
        Page<SRegionalCompanyArea> page = new Page<>();
        page.setCurrent(pageNumber);
        EntityWrapper wrapper = new EntityWrapper<>();
        wrapper.setEntity(sRegionalCompanyArea);
        page = sRegionalCompanyAreaService.selectPage(page,wrapper);
        restResult.setData(page);
        return restResult;
    }

    @GetMapping("/getSRegionalCompanyArea/{id}")
    @ApiOperation(
            value = "地区公司与地区的关联关系对象ID获取接口",
            notes = "地区公司与地区的关联关系对对象ID获取接口",
            response = SRegionalCompanyArea.class
    )
    public RestReturnResult addSRegionalCompanyArea(@PathVariable String id) {
    	RestReturnResult restResult = RestReturnResult.success();
        SRegionalCompanyArea sRegionalCompanyArea = sRegionalCompanyAreaService.selectById(id);
        restResult.setData(sRegionalCompanyArea);
        return restResult;
    }

    @PostMapping("/add")
    @ApiOperation(
            value = "地区公司与地区的关联关系添加接口",
            notes = "地区公司与地区的关联关系添加接口",
            response = SRegionalCompanyArea.class
    )
    public RestReturnResult add(@RequestBody SRegionalCompanyArea sRegionalCompanyArea) {
    	RestReturnResult restResult = RestReturnResult.success();
        sRegionalCompanyAreaService.insert(sRegionalCompanyArea);
        restResult.setData(sRegionalCompanyArea);
        return restResult;
    }

    @PutMapping("/update")
    @ApiOperation(
            value = "地区公司与地区的关联关系更新接口",
            notes = "地区公司与地区的关联关系更新接口",
            response = SRegionalCompanyArea.class
    )
    public RestReturnResult update(@RequestBody SRegionalCompanyArea sRegionalCompanyArea) {
    	RestReturnResult restResult = RestReturnResult.success();
        sRegionalCompanyAreaService.updateById(sRegionalCompanyArea);
        restResult.setData(sRegionalCompanyArea);
        return restResult;
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(
            value = "地区公司与地区的关联关系通过ID删除接口",
            notes = "地区公司与地区的关联关系通过ID删除接口",
            response = SRegionalCompanyArea.class
    )
    public RestReturnResult update(@PathVariable String id) {
    	RestReturnResult restResult = RestReturnResult.success();
        sRegionalCompanyAreaService.deleteById(id);
        return restResult;
    }
    
    @PostMapping("/saveOrUpdateRegionalCompanyArea")
    @ApiOperation(value = "地区公司与地区的关联关系更新接口",notes = "地区公司与地区的关联关系")
    public RestReturnResult saveOrUpdateRegionalCompanyArea(@RequestBody SRegionalCompanyAreaUpdateRequestVO vo){
    	RestReturnResult restResult = RestReturnResult.success();
    	
    	restResult = sRegionalCompanyAreaService.saveOrUpdateRegionalCompanyArea(vo);
    	
    	return restResult;
    }

}

